package com.oocl.ita.servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.oocl.ita.dao.impl.PersonDao;
import com.oocl.ita.dao.impl.PersonDaoImpl;
import com.oocl.ita.po.Person;

/**
 * Servlet implementation class QueryPersonServlet
 */
public class QueryPersonServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
    private PersonDao personDao;
    public QueryPersonServlet() {
        super();
        personDao = new PersonDaoImpl();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		List<Person> persons = new ArrayList<>();
		Person person = personDao.loadPerson(Integer.parseInt(request.getParameter("id")));
		persons.add(person);
		request.setAttribute("personList", persons);
		request.getRequestDispatcher("/ShowPersonServlet").forward(request, response);
	}

}
